include<tools/util.scad>
include<BOSL2/std.scad>
$fn=100;

b_l=340;
b_w=180;
b_h=15;

base();
//连接梁
//translate([-40,10,0])cube([28,9.6,9.6]);
//支架管
//translate([-40,-40,0])link_cy_begin();
//translate([-40,-70,0])link_cy_end();
//translate([-40,-100,0])link_cy_mid();
module base(){
    half_base();
   mirror([0,1,0])half_base();
}
module half_base(){
    b_lh=b_l/2;
    b_wh=b_w/2;
    difference(){
        union(){
            cube([b_lh,b_wh,b_h]);
            translate([1,b_wh-21,b_h])foot_hole();
            //多层连接孔
        }
        translate([11,b_wh-11,0])cylinder(h=b_h/2,d=15.3);
        
        translate([21,1,3])cube([b_lh-38,b_wh-6,b_h]);
        for(h_x=[21:22:b_lh-20]){
            for(h_y=[2:7:b_wh-6]){
                translate([h_x,h_y,-0.1])cube([20,5,b_h+1.2]);
            }
        }
        //拼接方孔
        translate([b_lh-15,b_wh-15,2.5])cube([15.1,10,10]);
        translate([b_lh-15,15,2.5])cube([15.1,10,10]);
        
        //倒圆
        translate([0,b_wh,b_h/2])rotate([0,0,-90])rounding_edge_mask(l=b_h, r=1);
        
        translate([b_lh/2,b_wh,b_h])rotate([90,90,-90])rounding_edge_mask(l=b_lh, r=1);
        translate([b_lh/2,b_wh,0])rotate([90,-90,90])rounding_edge_mask(l=b_lh, r=1);
        
        translate([0,b_wh/2,0])rotate([90,0,0])rounding_edge_mask(l=b_wh, r=1);
        translate([0,b_wh/2,b_h])rotate([90,90,0])rounding_edge_mask(l=b_wh, r=1);
    }
}
module foot_hole(){
    cube([20,20,1]);
    translate([10,10,1])difference(){
        cylinder(h=15,d=19);
        cylinder(h=15.1,d=15.3);
    }

}

module link_cy_begin(){
    difference(){
        cylinder(h=120,d=15);
        translate([0,0,1])cylinder(h=120,d=12);
        translate([0,0,90])cylinder(h=30.1,d=13.5);
    }
}
module link_cy_end(){
    difference(){
        union(){
            cylinder(h=90,d=15);
            translate([0,0,90])cylinder(h=30,d=13.2);
        }
            
        translate([0,0,1])cylinder(h=120,d=12);

    }
}
module link_cy_mid(){
    difference(){
        union(){
            cylinder(h=30,d=13.2);
            translate([0,0,30])cylinder(h=60,d=15);
            translate([0,0,90])cylinder(h=30,d=13.2);
        }
            
      cylinder(h=120.1,d=12);

    }
    
}
